package com.ycy.wechatservice.controller;

import com.ycy.wechatservice.config.WechatAccountConfig;
import me.chanjar.weixin.common.bean.WxJsapiSignature;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.Map;

@Controller
@RequestMapping("/wechattool")
public class WechatToolsController {

    @Autowired
    private WechatAccountConfig wechatAccountConfig;

    @Autowired
    private WxMpService wxMpService;

    @RequestMapping(value = "get_wx_config", method = RequestMethod.GET)
    public String test(Map<String, Object> map) {
        //System.out.println(wechatAccountConfig.getAppId());
/*        WxJsapiSignature wxJsapiSignature;
        try {
            wxJsapiSignature = wxMpService.createJsapiSignature("http://ycy.tunnel.echomod.cn/wechatservice/wechattool/get_wx_config");
            map.put("wxJsapiSignature",wxJsapiSignature);
        } catch (WxErrorException we) {
            System.out.println(we);
        }*/

        map.put("msg","成功");
        map.put("url","https://www.baidu.com");

        return "success";
    }
}
